{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5f027953",
   "metadata": {},
   "outputs": [],
   "source": [
    "#记得安装下面两个库\n",
    "import jieba\n",
    "import wordcloud\n",
    "\n",
    "f=open(\"C:\\\\Users\\\\30382\\\\Desktop\\\\二维码\\\\mjp.txt\",\"r\",encoding=\"UTF-8\") #在桌面创了一个二维码的文件夹，里面放一个txt的文本，文本内容是自己的兴趣爱好\n",
    "t=f.read()\n",
    "f.close()\n",
    "ls=jieba.lcut(t)\n",
    "txt=\"\".join(ls)\n",
    "\n",
    "#格式设置\n",
    "w=wordcloud.WordCloud(font_path=\"C:\\Windows\\Fonts\\Deng.ttf\",\n",
    "                      width=1000,height=700,\n",
    "                      background_color=\"white\")\n",
    "w.generate(txt)\n",
    "\n",
    "w.to_file(\"C:\\\\Users\\\\30382\\\\Desktop\\\\二维码\\\\爬取结果.png\") #生成词云，保存到二维码文件中"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
